﻿@model Wiwi.ViewModels.ProfileView
@{
    ViewBag.Title = "Wiwi Pitch";

}

@* !#! okkk, this is what was left from the previous developer
    # With kents Attempt to clean/smarten up 
*@

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@*<link href="@Url.Content("~/Content/css/SiteModal.css")" rel="stylesheet" type="text/css" />*@
@*
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-ui-1.8.6.custom.min.js")"></script>

<script src="@Url.Content("~/Scripts/jquery.simplemodal-1.4.1.js")" type="text/javascript"></script>
*@

<script type="text/javascript" src="@Url.Content("~/Scripts/MicrosoftAjax.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")"></script>





<!-- -->

<div class="grid_8 box-shadow margin-top">
    	<h4 class="tabbed">WiWi Pitch</h4>

@using (Html.BeginForm("Pitch", "Want", FormMethod.Post, new { id = "FrmPitch" }))
{
    <input type="hidden" id="FuncExec" />
    <input type="hidden" id="Crbal" />
    <input type="hidden" id="HidPitch" name="HidPitch" /> @* Used for user ID *@
    
     <div class="wiwi-pitches-box">
      
            @* !#! needs users image *@
            <div class="left-col"> 
			        <a href="#"><img src="." width="48" height="48" alt="userName" /></a> 
	        </div> 
    
    @if (Model.Want.Count > 0)
    {
   
       <div class="right-col bigger-icon">

            <p class="serif-it">@Model.Want[0].WantDesc</p>

                <p class='tagged'>Tagged ~
                     @if (Model.Want[0].Tags != "")
                     {
                         string[] TagRows = Model.Want[0].Tags.Split('$');
                         foreach (string tr in TagRows)
                         {
                             if (tr != "")
                             {
                                 string[] Tagss = tr.Split('?');
                                 if (Tagss[0].Trim() != "")
                                 {
                                    <a href='/Want/Pitch?Wuid=@Tagss[1].ToString()'>@Tagss[0]</a>
                                 }
                             }
                         }

                     }
                 </p>
        </div>
    }
    
    <hr />

   @foreach (var wnt in Model.Want)
   {      
      <!-- ## -->
    <div class="wiwi-pitches-box">
	
		<div class="left-col">
            <a href="Home/UserPublicProfile?Uid=@wnt.UserID" ><img height ="48px" width="48" src='@Url.Action("ShowUserImage", "Home", new { Uid = @wnt.UserID })' /></a>
        </div>
		
		<div class="right-col bigger-icon">
        
        @if (wnt.PitchForSupplier != "")
        {
             <ul class="user-choice">
             @if (wnt.PitchForSupplier == "Accepted")
             {
                        <li class="button-s green-button xWide">Pitch Accepted!</li>
             }
                   @if (wnt.PitchForSupplier == "Declined")
                   { <li class="button-m pitch red-button">Pitch Declined</li> }
                   @if (wnt.PitchForSupplier == "Awaiting")
                   { <li class="button-m pitch grey-button">Pitch Pending</li> }
                                                                                                                        
            </ul>
            
        }

	    	<h5>@wnt.FName.ToString()  @if (wnt.Lname != null)
                                 { @wnt.Lname.ToString() }
               <br />
               @if (wnt.WiwiDate.Value != null)
               {
                   string durat = "";
                   if (wnt.IsCreator == true) { durat = "Posted "; }
                   else { durat = "Me2'd "; }

                   TimeSpan span = DateTime.Now - wnt.WiwiDate.Value;
                   if (span.Minutes < 59 && span.Hours < 1 && span.Days < 1)
                   {
                       durat += span.Minutes.ToString() + " Minutes ago";
                   }
                   if (span.Hours > 1 && span.Days < 1)
                   {
                       durat += span.Hours.ToString() + " Hours ago";
                   }
                   if (span.Days > 1)
                   {
                       durat += span.Days.ToString() + " Days ago";
                   }
                 <span >@durat</span>
               }
               </h5>
    		<p class="wiwi-content">@Html.ActionLink(wnt.WantDesc.ToString(), "WiwiDetails", "Home", new { wntID = wnt.WantID, UsrID = wnt.UserID }, null)</p>  

                @{
                         string TxtID = "T_" + wnt.Want_Wanter_RelID.ToString();        
                 }
                @if (wnt.PitchForSupplier == "")
                {
                <textarea cols="47" rows="4" class="wiwi-pitch-textarea serif-it" id ="@TxtID" name="@TxtID">Enter your Pitch</textarea>
             
                      <p class="green fRight margin-right click"><input type="button" id="sendPitch" value="Send Pitch" class="button-m" onclick="return SetHiddenValue('@wnt.Want_Wanter_RelID');" /></p>
              
                 @*
                <input type="button" id="sendPitch" value="Send Pitch" class="button-m" onclick="return;" />
                  *@  
                } @* else if (wnt.PitchForSupplier == "Accepted")
                    {
                        
                        <p class="fRight margin-right">@Html.ActionLink("Reply", "WantComm", "Want", new { Wid = wnt.Want_Wanter_RelID,SuppID= }, new { @class = "button-m pitch blue-button" })</p>
                    }*@
	    </div>
	</div>    
        
	<hr class="mini" />   
   }



</div>
    
}

 </div>

 <script type="text/javascript">
    
        /*
        $('#sendPitch').click(function () {

        $('body').append('<div id="creditBox" />')
        $('#creditBox').load("/Want/CreditBuy");

        });
        */

        /*
        //$("#auth_modal_container").css("display", "block");
        $("#payment_update").load("/Want/CreditBuy");
        $('#auth_modal_container').dialog({
        autoOpen: false,
        bgiframe: true,
        height: 450,
        width: 300,
        modal: true,
        title: " Payment"
        });
       
        });
        */

        var bal = 0;
        $('#FuncExec').val(0);
        $('#Crbal').val(0);

        function SetHiddenValue(wid) {
            $('#HidPitch').val(wid);
            $.post("/Want/UserCreditbalance", null,
	        function (data) {
	            $('#FuncExec').val('1');
	            $('#Crbal').val(data);
	            if (data < 300) { // change back to '3' 
	                //  $("#auth_modal_container").dialog('open');
	                //  $("#auth_modal_container").css("display", "block");
	                //  $("#payment_update").load("/Want/CreditBuy");
	                $('body').append('<div id="creditBox" />')
	                $('#creditBox').load("/Want/CreditBuy");
	            }
	            else {
	                //     $("#auth_modal_container").dialog('close');
	                //     $("#auth_modal_container").css("display", "none");
	                $("#FrmPitch").submit();
	            }
	        });
        }

 
	        

            // SubmitForm();
  
/*
    function SubmitForm() {
        
        if ($('#Crbal').val() < 3) {
           //             $("#auth_modal_container").dialog('open');
           //             $("#auth_modal_container").css("display", "block");
           //             $("#payment_update").load("/Want/CreditBuy");
        }
        else {
            $("#auth_modal_container").dialog('close');
            $("#auth_modal_container").css("display", "none");
            $("#FrmPitch").submit();
        }
    }
 */
 
</script>
    
